/**
 * @description 查询表单 目前不支持combo
 * @param {} options 必要参数：id、search（查询回调函数）、items（自定义的查询项）{必要参数：text、name}
 */
var searchForm = function(options) {
    if(!options){options={}};
    if(!options.id){alert("没有id");return;};
    
    var baseSerach = {
                style : "margin-left: 5px;",
                xtype : "button",
                text : "搜索",
//                scope : this,
                iconCls : "search",
                handler : options.search
            };
     var baseReset = {
                style : "margin-left: 10px;",
                xtype : "button",
                text : "清空",
                scope : this,
                iconCls : "reset",
                //handler : Ext.getCmp(options.id).getForm().reset()
                listeners : {
                    click : function(){
                        Ext.getCmp(options.id).getForm().reset();
                    }
                }
            };
     var items = options.items;
     var searchConditions = [];
     
     if(items || options.extend){
        var objlabel = {};
        var objtext = {};
        
        for(var i =0; i < items.length; i++){
             objlabel =  {
                            style : "margin:0px 5px 5px 5px",
                            text : items[i].text == null || items[i].text == 'undefined' ? "零组件编号:" : items[i].text
                         };
             objtext =  {
                            columnWidth : items[i].columnWidth == null || items[i].columnWidth == 'undefined' ? 0.2 : items[i].columnWidth,
                            xtype : items[i].xtype == null || items[i].xtype == 'undefined' ? "textfield" : items[i].xtype,
                            width : 110,
                            name : items[i].name,
                            maxLength : items[i].maxLength == null || items[i].maxLength == 'undefined' ? 256 : items[i].maxLength
                        };
             searchConditions.push(objlabel);
             searchConditions.push(objtext);
        }
        if(options.extend){
            for(var i = 0; i< (options.extend).length; i++){
                searchConditions.push(options.extend[i]);
            }
        }
        
        //添加查询和清空按钮
        searchConditions.push(baseSerach);
        searchConditions.push(baseReset);
     }else{
     	alert("没有定义查询项");
        return;
     }
    
    var searchFormPanel =  new Ext.FormPanel({
        id : options.id,
//        title : '查询条件',
        height : options.height == null || options.height == 'undefined' ? 40 : options.height,
        frame : false,
        border : false,
        region : options.region == null || options.region == 'undefined' ? "north" : options.region,
        layout : "hbox",
        defaults : {
            xtype : "label",
            border : false,
            margins : {
                top : 0,
                right : 4,
                bottom : 0,
                left : 4
            }
        },
        layoutConfig : {
        	padding : "5",
            align : "middle"
        },
        items : searchConditions
    });
    
    return searchFormPanel;
}